package pk.nak.requests;

import java.util.ArrayList;
import pk.nak.enums.TossDownURLs;
import pk.nak.responses.CreateUserResponse;
import pk.nak.utils.FormattingUtils;

import com.loopj.android.http.RequestParams;

public class CreateUserRequest extends PostRequest {

	public CreateUserRequest(String name, String username,
							String password, String email,
							String dob, String gender,
							String country, String city) {
		
		super(TossDownURLs.ADD, null);
		/*
		?outh_key=P2N456Uj0trny75J12L6SUQ7458
		&name=abc
		&username=nauman
		&password=123456789
		&email=chhameed@facebook.com
		&dob=09/03/1989
		&gender=male
		&country=pakistan
		&city=lahore
		 */
		
		RequestParams parms = new RequestParams();

		ArrayList<String> fields = new ArrayList<String>();
		ArrayList<String> values = new ArrayList<String>();
		
		fields.add("username");
		values.add(FormattingUtils.IntoDBFormat(username));
		
		fields.add("password");
		values.add(FormattingUtils.IntoDBFormat(password));
		
		fields.add("email");
		values.add(FormattingUtils.IntoDBFormat(email));
		
		fields.add("dob");
		values.add(FormattingUtils.IntoDBFormat(dob));
		
		fields.add("gender");
		values.add(FormattingUtils.IntoDBFormat(gender));
		
		String ff = FormattingUtils.getJoin(fields, ",");
		String fv = FormattingUtils.getJoin(values, ",");
		
		parms.put("table", "users");
		parms.put("fields", ff);
		parms.put("values", fv);
		/*
		parms.put("outh_key", AppVars.OUTH_KEY);
		parms.put("name",name );
		parms.put("username", username);
		parms.put("password", password);
		parms.put("email",email );
		parms.put("dob",dob );
		parms.put("gender", gender);
		parms.put("country",country );
		parms.put("city", city);
		*/
		this.setData(parms);
	}

	public void doRequest(CreateUserResponse responseHandler) {
		super.doRequest(responseHandler);
	}

}
